max

 

Max reports the maximum value in a given list. For example, show max [1 2 3] will return 3. Max is commonly used on a specific variable of an agentset, which would look like max [variable] of agentset. So

ask turtles with max [size] of turtles [ set color white ]

would set the largest turtle or turtles to white.

 

Try it Yourself

 
 
 
 
 
 
 

What's next?

Once you mastered the max primitive, don't stop there. Check out the resources below to improve your NetLogo skills.

 
Published NetLogo models that use the max primitive:
 
 
Similar primitives:
max-n-of

Gives a list of top values of a list.

Read more
mean

Find the mean of a list of values.

Read more
of

report the value of an agent-owned variable from another context

Read more
 
Learn another primitive